Ext.define('PJ.view.submittrainingplanviews.FillOpinionsView', {
	extend: 'AM.default.DefaultWindowForm',
	alias: ['widget.fillOpinionsView'],
	requires: ['AM.default.DefaultDateField', 
	           'AM.default.DateTime',
	           'AM.default.jsonp.DefaultSubmitJsonp',
	           'AM.default.DefaultDateField'
	           ],

	modal: true,// 开启不允许点击其他组件
	frame: true,
	notEdit: true,
	width: 650,
	layout: 'form',
	isSame: false,
	height: 430,
	overflowY:'auto',
	initComponent: function(){
    	var me = this;
    	me.items= [{
    		defaults: {
    			labelAlign: 'right',
    			labelWidth: 90,
    			columnWidth: .5,
    			padding:"9 0 0 0",
    			readOnly:me.isView
    		},
    		border: false,
    		xtype: "container",
    		id: 'fillOpinionsContainer',
    		itemId: 'fillOpinionsContainer',
    		width: 610,
//    		height:430,
    		layout: 'column',
    		allowBlank: false,
    		items: [{
    			xtype: 'textfield',
    			fieldLabel: '培训班名称',
    			name: 'className',
    			allowBlank: true,
    			readOnly:true,
                listeners: {
                	change: function(textField){
                		if(textField.getValue() && textField.getValue().length > 50){
                			Orchid.alert('提示','该输入项最多输入50个字符！');
                		}
                	}
                },
                maxLength: 50
    		},{
    			xtype: 'textfield',
    			fieldLabel: '计划申请编号',
    			name: 'applyNum',
    			readOnly:true,
    			allowBlank: true
//    			emptyText: '请输入8位数字或字母',
//    			regex: /^[A-Za-z0-9]{1,8}$/,
//    			regexText: '培训班编号只能输入8位长度的数字或字母！'
    		},{
    			xtype: 'textfield',
    			fieldLabel: '反馈单位',
    			name: 'depName',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		},{
    			xtype: 'textfield',
    			fieldLabel: '反馈时间',
    			name: 'feedbackDateStr',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		},{
    			xtype: 'textfield',
    			fieldLabel: '承办部委',
    			name: 'undertakeName',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		},{
    			xtype: 'textfield',
    			fieldLabel: '合办部委',
    			name: 'jointName',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		},/*{
    			xtype: 'textfield',
    			fieldLabel: '计划时间',
    			name: 'planDate',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		},*/{
    			xtype: 'textfield',
    			fieldLabel: '计划开始时间',
    			name: 'startPlanDateStr',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		},{
    			xtype: 'textfield',
    			fieldLabel: '计划结束时间',
    			name: 'endPlanDateStr',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		}, {
    			xtype: 'textfield',
    			fieldLabel: '学制（天）',
    			name: 'planDay',
    			allowBlank: true,
    			readOnly:true,
    			columnWidth: .5
    		},{
    			xtype: 'hidden',
    			name: 'planId'//培训班Id
    		}]
    	}];
		this.buttons = [{
			text:"确定",
			scope:this,
			hidden:me.isReadOnly,
			handler:function(btn){
				var win = me;
				var form = win.down('form');
				var baseForm = form.getForm();
//				var classNum = baseForm.findField("applyNum");
//				if(classNum_ != null && classNum_.getValue() != null && classNum_ != ""){
//					baseForm.findField("classNum").setValue(classNum_.getValue());
//				}
				if (!baseForm.isValid()) {
					return;
				}
				var url = "";
				var params = {};
				if(me.flag==1){				//1 新增  2 修改   3 完善
					url = me.grid.store.addUrl;
				}else if(me.flag==2){
					url = me.grid.store.updateUrl;
				}else if(me.flag==3){
					url = me.grid.store.derfectUrl;
					params = {
						className: win.className,
						ministrieName: win.ministrieName
					};
				}
				
				if(gj_onlineLearning_constant.loadType == "jsonp"){
					baseForm.doAction('submitJsonp',{
						submitEmptyText: false,//忽略emptyValue
						url: url,
						params: params,
						success: function(f, action){
							if (action.result.success) {
								Orchid.alert('消息', "操作成功!", function(){
									var gridPanel = win.grid;
									var store = gridPanel.getStore();
									store.reload();
									win.close();
								});
							}else{
								Orchid.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
									win.close();
								});
							}
						},
						failure: function(f, action){
							Orchid.alert('错误', action.result.msg||"系统出错,请联系管理员!");
						}
					});
				}else{
					form.submit({
						submitEmptyText: false,//忽略emptyValue
						url: url,
						params: params,
						success: function(f, action){
							if (action.result.success) {
								Orchid.alert('消息', "操作成功!", function(){
									var gridPanel = win.grid;
									var store = gridPanel.getStore();
									store.reload();
									win.close();
								});
							}else{
								Orchid.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
									win.close();
								});
							}
						},
						failure: function(f, action){
							Orchid.alert('错误', action.result.msg||"系统出错,请联系管理员!");
						}
					});
				}
			}
		},{
			text: '关闭',
			scope: this,
			handler: this.close
		}];
		this.callParent(arguments);
	}
});